package com.ruoyi.web.controller.teaching;

import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.teaching.service.MailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/mail")
@Api(tags = "邮箱验证/短信验证")
public class MailController {
    @Autowired
    private MailService mailService;

    @PostMapping("/mail/qq")
    @ApiOperation(value = "qq邮箱验证",notes = "补充手机号短信验证")
    public AjaxResult register(String mail) {
        String s=null;
        if (mail == null||mail.equals("")) {
            return new AjaxResult(HttpStatus.ERROR,"邮箱或手机号不能为空");
        }else if (mail.contains("@")) {
             s = mailService.sendEmail(mail);
        }else if (mail.length() == 11) {
             s = mailService.sendPhone(mail);
        }
        return new AjaxResult(HttpStatus.SUCCESS,s);
    }

//    @PostMapping("/mail/phone")
//    @ApiOperation("手机号验证")
//    public AjaxResult phone(String phone) {
//        String s = mailService.sendPhone(phone);
//        return new AjaxResult(HttpStatus.SUCCESS,s);
//    }


}
